package com.example.dangerouscargodriver.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.example.dangerouscargodriver.R;
import com.example.dangerouscargodriver.utils.AppManager;
import com.example.dangerouscargodriver.widget.ActionBar;

public class EnterPlatformCompanySuccessActivity extends AppCompatActivity implements View.OnClickListener {

	private ActionBar mActionBar = null;
	private TextView mReturnHome = null;
	private TextView mSeeDetail = null;

	private String mCid = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_enter_platform_company_success);

		mCid = getIntent().getStringExtra("cid");

		mReturnHome = findViewById(R.id.tv_return_home);
		mReturnHome.setOnClickListener(this);
		mSeeDetail = findViewById(R.id.tv_see_detail);
		mSeeDetail.setOnClickListener(this);

		mActionBar = findViewById(R.id.actionBarEnterPlatformSuccess);
		mActionBar.setOnBackClickListener( new View.OnClickListener(){

			@Override
			public void onClick(View v) {
				AppManager.getAppManager().finishActivity();
				AppManager.getAppManager().finishActivity();
				finish();
			}
		});
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			AppManager.getAppManager().finishActivity();
			AppManager.getAppManager().finishActivity();
			finish();
		}
		return super.onKeyDown(keyCode, event);
	}

	@Override
	public void onClick(View v) {
		if(v.getId() == R.id.tv_return_home){
			AppManager.getAppManager().finishActivity();
			AppManager.getAppManager().finishActivity();
			finish();
		}
		else if(v.getId() == R.id.tv_see_detail){
			AppManager.getAppManager().finishActivity();
			AppManager.getAppManager().finishActivity();
			finish();
			Intent intent = new Intent(this, CompanyDetailActivity.class);
			if(mCid != null){
				intent.putExtra("cid", mCid);
			}
			startActivity(intent);
		}
		else{

		}
	}
}